package com.teach.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.teach.dto.ShopOrderDTO;
import com.teach.dto.ShopOrderItemSearch;
import com.teach.dto.ShopOrderSearch;
import com.teach.entity.Product;
import com.teach.entity.ShopOrder;
import com.teach.entity.ShopOrderItem;
import com.teach.mapper.ShopOrderItemMapper;
import com.teach.service.shop.ShopOrederService;
@Service
public class ShopOrderServiceImpl implements ShopOrederService{

	@Autowired
	private ShopOrderItemMapper mapper;
	
	@Override
	public PageInfo<ShopOrderDTO> page(ShopOrderSearch search) {
		PageInfo<ShopOrderDTO> page = PageHelper.startPage(search.getCurrent(), search.getRowMax()).doSelectPageInfo(()->{
			mapper.select(search);
		});
		return page;
	}

	@Override
	public void delete(Long orderId) {
		mapper.deleteByOrderId(orderId);
	}

	@Override
	public ShopOrderItem select(Long shopOrderItemId) {
		return mapper.selectByPrimaryKey(shopOrderItemId);
	}
	
	
	@Override
	public void doOrderFH(ShopOrderItem shopOrderItemId) {
		System.out.println(shopOrderItemId);
		mapper.updateByPrimaryKeySelective(shopOrderItemId);
	}

	@Override
	public PageInfo<ShopOrderItem> page(ShopOrderItemSearch search) {
		PageInfo<ShopOrderItem> page = PageHelper.startPage(search.getCurrent(), search.getRowMax()).doSelectPageInfo(()->{
			mapper.selects(search);
		});
		return page;
	}

	@Override
	public void update(Integer state, Long orderId) {
		mapper.update(state, orderId);
	}

}
